home *** CD-ROM | disk | FTP | other *** search
- /* Copyright (c) Silicon Graphics, Inc. 1996 */
-
- /*
- Demonstrate using combinations of single/double and index/rgb simultaneously.
- G. Edwards, SG UK, Jan 04 94.
- */
-
- #include <GL/gl.h>
- #include <GL/glut.h>
- #include <stdio.h>
- #include <string.h>
- #include <stdlib.h>
- #include <unistd.h>
-
- GLboolean si = GL_FALSE, sr = GL_FALSE, di = GL_FALSE, dr = GL_FALSE;
-
- #define EQ(str1, str2) (strcmp((str1),(str2)) == 0)
- #define NEQ(str1, str2) (strcmp((str1),(str2)) != 0)
-
- void
- drawSIscene( GLvoid )
- {
- glClearIndex(15);
- glClear(GL_COLOR_BUFFER_BIT);
- }
-
- void
- drawDIscene( GLvoid )
- {
- glClearIndex(5);
- glClear(GL_COLOR_BUFFER_BIT);
- glutSwapBuffers();
- }
-
- void
- drawSRscene( GLvoid )
- {
- glClearColor(0.2, 0.5, 0.7, 1.0);
- glClear(GL_COLOR_BUFFER_BIT);
- }
-
- void
- drawDRscene( GLvoid )
- {
- glClearColor(0.5, 0.5, 0.5, 1.0);
- glClear(GL_COLOR_BUFFER_BIT);
- glutSwapBuffers();
- }
-
- void
- keyboard( GLubyte key, GLint x, GLint y )
- {
- if (key == 27) /* escape */
- exit(0);
- }
-
- void main(int argc, char *argv[])
- {
- int i = 0;
-
- glutInit( &argc, argv );
-
- /* Help */
-
- if (argc < 2)
- {
- fprintf(stderr, "Usage: %s [si] [sr] [di] [dr]\n", argv[0]);
- exit (-1);
- }
-
- /* Pick window modes from command line */
-
- while (++i < argc)
- {
- if (EQ(argv[i], "si"))
- si = GL_TRUE;
- if (EQ(argv[i], "sr"))
- sr = GL_TRUE;
- if (EQ(argv[i], "di"))
- di = GL_TRUE;
- if (EQ(argv[i], "dr"))
- dr = GL_TRUE;
- }
-
- /* Single buffered cmap */
-
- if (si)
- {
- glutInitDisplayMode(GLUT_INDEX | GLUT_SINGLE);
- glutInitWindowPosition(100, 100);
- glutInitWindowSize( 400, 100);
- glutCreateWindow("Single Cmap");
- glutSetColor(15, 0.5, 0.5, 0.5);
- glutDisplayFunc( drawSIscene );
- glutKeyboardFunc( keyboard );
- }
-
- /* Single buffered RGB */
-
- if (sr)
- {
- glutInitDisplayMode(GLUT_RGBA | GLUT_SINGLE);
- glutInitWindowPosition(100, 300);
- glutInitWindowSize( 400, 100);
- glutCreateWindow("Single Rgb");
- glutDisplayFunc( drawSRscene );
- glutKeyboardFunc( keyboard );
- }
-
- /* Double buffered cmap */
-
- if (di)
- {
- glutInitDisplayMode(GLUT_INDEX | GLUT_DOUBLE);
- glutInitWindowPosition(100, 500);
- glutInitWindowSize( 400, 100);
- glutCreateWindow("Double Cmap");
- glutSetColor(5, 0.2, 0.5, 0.7);
- glutDisplayFunc( drawDIscene );
- glutKeyboardFunc( keyboard );
- }
-
- /* Double buffered RGB */
-
- if (dr)
- {
- glutInitDisplayMode(GLUT_RGBA | GLUT_DOUBLE);
- glutInitWindowPosition(100, 700);
- glutInitWindowSize( 400, 100);
- glutCreateWindow("Double Rgb");
- glutDisplayFunc( drawDRscene );
- glutKeyboardFunc( keyboard );
- }
-
-
- glutMainLoop();
- }
-